package com.xxh.user.mq;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


//@Configuration
public class MqConfig {

    public final static String SMSQUEUE="smsqueue";
    public final static String SMSKEY="smsevent";


    public final static String EmailQUEUE="emailqueue";
    public final static String EmailKEY="emailevent";


    public  final static  String LogQueue ="logqueue";
    public final static String LogKEY="logevent";


    //声明队列
    @Bean
    Queue smsQueue(){
       return new Queue(SMSQUEUE);
    }
    @Bean
    Queue emailQueue(){
        return new Queue(EmailQUEUE);
    }
    @Bean
    Queue logQueue(){
        return  new Queue(LogQueue);
    }



    //声明交换机
    @Bean
    DirectExchange exchange(){
        return new DirectExchange("xxvideo");
    }

    //队列绑定交换机
    @Bean
    Binding bindSms(){
        return BindingBuilder.bind(smsQueue()).to(exchange()).with(SMSKEY);
    }
    @Bean
    Binding bindEmail(){
        return BindingBuilder.bind(emailQueue()).to(exchange()).with(EmailKEY);
    }

    @Bean
    Binding bindLog(){
        return  BindingBuilder.bind(logQueue()).to(exchange()).with(LogKEY);
    }
}
